namespace Teleware.Newbe.Navigation.Web.Migrations
{
    using System;
    using System.Collections.Generic;
    using System.Data.Entity.Infrastructure.Annotations;
    using System.Data.Entity.Migrations;
    
    public partial class InitCreation : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Accounts",
                c => new
                    {
                        Id = c.Long(nullable: false, identity: true),
                        Name = c.String(nullable: false),
                        UserId = c.String(nullable: false),
                        DepartmentId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Departments", t => t.DepartmentId, cascadeDelete: true)
                .Index(t => t.DepartmentId);
            
            CreateTable(
                "dbo.Departments",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Name = c.String(nullable: false),
                        OrderNo = c.String(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
            CreateTable(
                "dbo.HrefInfoes",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Name = c.String(nullable: false),
                        Href = c.String(nullable: false),
                        Remark = c.String(),
                        DepartmentId = c.String(nullable: false, maxLength: 128),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeletionTime = c.DateTime(),
                        DeleterUserId = c.Long(),
                        OrderNo = c.String(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_HrefInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Accounts", t => t.CreatorUserId)
                .ForeignKey("dbo.Accounts", t => t.DeleterUserId)
                .ForeignKey("dbo.Departments", t => t.DepartmentId, cascadeDelete: true)
                .ForeignKey("dbo.Accounts", t => t.LastModifierUserId)
                .Index(t => t.DepartmentId)
                .Index(t => t.CreatorUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId);
            
            CreateTable(
                "dbo.HrefInfoTags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        HrefInfoId = c.String(nullable: false, maxLength: 128),
                        InfoTagId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.HrefInfoes", t => t.HrefInfoId, cascadeDelete: true)
                .ForeignKey("dbo.InfoTags", t => t.InfoTagId, cascadeDelete: true)
                .Index(t => t.HrefInfoId)
                .Index(t => t.InfoTagId);
            
            CreateTable(
                "dbo.InfoTags",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Text = c.String(nullable: false),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeletionTime = c.DateTime(),
                        DeleterUserId = c.Long(),
                        OrderNo = c.String(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_InfoTag_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Accounts", t => t.CreatorUserId)
                .ForeignKey("dbo.Accounts", t => t.DeleterUserId)
                .ForeignKey("dbo.Accounts", t => t.LastModifierUserId)
                .Index(t => t.CreatorUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId);
            
            CreateTable(
                "dbo.QqGroupInfoes",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        QqGroup = c.String(nullable: false),
                        QqGroupLink = c.String(),
                        Name = c.String(nullable: false),
                        Remark = c.String(),
                        DepartmentId = c.String(nullable: false, maxLength: 128),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeletionTime = c.DateTime(),
                        DeleterUserId = c.Long(),
                        OrderNo = c.String(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_QqGroupInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Accounts", t => t.CreatorUserId)
                .ForeignKey("dbo.Accounts", t => t.DeleterUserId)
                .ForeignKey("dbo.Departments", t => t.DepartmentId, cascadeDelete: true)
                .ForeignKey("dbo.Accounts", t => t.LastModifierUserId)
                .Index(t => t.DepartmentId)
                .Index(t => t.CreatorUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId);
            
            CreateTable(
                "dbo.QqGroupInfoTags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        QqGroupInfoId = c.String(nullable: false, maxLength: 128),
                        InfoTagId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.InfoTags", t => t.InfoTagId, cascadeDelete: true)
                .ForeignKey("dbo.QqGroupInfoes", t => t.QqGroupInfoId, cascadeDelete: true)
                .Index(t => t.QqGroupInfoId)
                .Index(t => t.InfoTagId);
            
            CreateTable(
                "dbo.QqInfoes",
                c => new
                    {
                        Id = c.String(nullable: false, maxLength: 128),
                        Qq = c.String(nullable: false),
                        Name = c.String(nullable: false),
                        Remark = c.String(),
                        DepartmentId = c.String(nullable: false, maxLength: 128),
                        CreationTime = c.DateTime(nullable: false),
                        CreatorUserId = c.Long(),
                        LastModificationTime = c.DateTime(),
                        LastModifierUserId = c.Long(),
                        IsDeleted = c.Boolean(nullable: false),
                        DeletionTime = c.DateTime(),
                        DeleterUserId = c.Long(),
                        OrderNo = c.String(),
                    },
                annotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_QqInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.Accounts", t => t.CreatorUserId)
                .ForeignKey("dbo.Accounts", t => t.DeleterUserId)
                .ForeignKey("dbo.Departments", t => t.DepartmentId, cascadeDelete: true)
                .ForeignKey("dbo.Accounts", t => t.LastModifierUserId)
                .Index(t => t.DepartmentId)
                .Index(t => t.CreatorUserId)
                .Index(t => t.LastModifierUserId)
                .Index(t => t.DeleterUserId);
            
            CreateTable(
                "dbo.QqInfoTags",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        InfoTagId = c.String(nullable: false, maxLength: 128),
                        QqInfoId = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.InfoTags", t => t.InfoTagId, cascadeDelete: true)
                .ForeignKey("dbo.QqInfoes", t => t.QqInfoId, cascadeDelete: true)
                .Index(t => t.InfoTagId)
                .Index(t => t.QqInfoId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.QqInfoTags", "QqInfoId", "dbo.QqInfoes");
            DropForeignKey("dbo.QqInfoTags", "InfoTagId", "dbo.InfoTags");
            DropForeignKey("dbo.QqInfoes", "LastModifierUserId", "dbo.Accounts");
            DropForeignKey("dbo.QqInfoes", "DepartmentId", "dbo.Departments");
            DropForeignKey("dbo.QqInfoes", "DeleterUserId", "dbo.Accounts");
            DropForeignKey("dbo.QqInfoes", "CreatorUserId", "dbo.Accounts");
            DropForeignKey("dbo.QqGroupInfoTags", "QqGroupInfoId", "dbo.QqGroupInfoes");
            DropForeignKey("dbo.QqGroupInfoTags", "InfoTagId", "dbo.InfoTags");
            DropForeignKey("dbo.QqGroupInfoes", "LastModifierUserId", "dbo.Accounts");
            DropForeignKey("dbo.QqGroupInfoes", "DepartmentId", "dbo.Departments");
            DropForeignKey("dbo.QqGroupInfoes", "DeleterUserId", "dbo.Accounts");
            DropForeignKey("dbo.QqGroupInfoes", "CreatorUserId", "dbo.Accounts");
            DropForeignKey("dbo.HrefInfoes", "LastModifierUserId", "dbo.Accounts");
            DropForeignKey("dbo.HrefInfoTags", "InfoTagId", "dbo.InfoTags");
            DropForeignKey("dbo.InfoTags", "LastModifierUserId", "dbo.Accounts");
            DropForeignKey("dbo.InfoTags", "DeleterUserId", "dbo.Accounts");
            DropForeignKey("dbo.InfoTags", "CreatorUserId", "dbo.Accounts");
            DropForeignKey("dbo.HrefInfoTags", "HrefInfoId", "dbo.HrefInfoes");
            DropForeignKey("dbo.HrefInfoes", "DepartmentId", "dbo.Departments");
            DropForeignKey("dbo.HrefInfoes", "DeleterUserId", "dbo.Accounts");
            DropForeignKey("dbo.HrefInfoes", "CreatorUserId", "dbo.Accounts");
            DropForeignKey("dbo.Accounts", "DepartmentId", "dbo.Departments");
            DropIndex("dbo.QqInfoTags", new[] { "QqInfoId" });
            DropIndex("dbo.QqInfoTags", new[] { "InfoTagId" });
            DropIndex("dbo.QqInfoes", new[] { "DeleterUserId" });
            DropIndex("dbo.QqInfoes", new[] { "LastModifierUserId" });
            DropIndex("dbo.QqInfoes", new[] { "CreatorUserId" });
            DropIndex("dbo.QqInfoes", new[] { "DepartmentId" });
            DropIndex("dbo.QqGroupInfoTags", new[] { "InfoTagId" });
            DropIndex("dbo.QqGroupInfoTags", new[] { "QqGroupInfoId" });
            DropIndex("dbo.QqGroupInfoes", new[] { "DeleterUserId" });
            DropIndex("dbo.QqGroupInfoes", new[] { "LastModifierUserId" });
            DropIndex("dbo.QqGroupInfoes", new[] { "CreatorUserId" });
            DropIndex("dbo.QqGroupInfoes", new[] { "DepartmentId" });
            DropIndex("dbo.InfoTags", new[] { "DeleterUserId" });
            DropIndex("dbo.InfoTags", new[] { "LastModifierUserId" });
            DropIndex("dbo.InfoTags", new[] { "CreatorUserId" });
            DropIndex("dbo.HrefInfoTags", new[] { "InfoTagId" });
            DropIndex("dbo.HrefInfoTags", new[] { "HrefInfoId" });
            DropIndex("dbo.HrefInfoes", new[] { "DeleterUserId" });
            DropIndex("dbo.HrefInfoes", new[] { "LastModifierUserId" });
            DropIndex("dbo.HrefInfoes", new[] { "CreatorUserId" });
            DropIndex("dbo.HrefInfoes", new[] { "DepartmentId" });
            DropIndex("dbo.Accounts", new[] { "DepartmentId" });
            DropTable("dbo.QqInfoTags");
            DropTable("dbo.QqInfoes",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_QqInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.QqGroupInfoTags");
            DropTable("dbo.QqGroupInfoes",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_QqGroupInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.InfoTags",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_InfoTag_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.HrefInfoTags");
            DropTable("dbo.HrefInfoes",
                removedAnnotations: new Dictionary<string, object>
                {
                    { "DynamicFilter_HrefInfo_SoftDelete", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                });
            DropTable("dbo.Departments");
            DropTable("dbo.Accounts");
        }
    }
}
